package com.zl.learning.io.zip;

import org.junit.Test;
import org.zeroturnaround.zip.ZipUtil;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.nio.file.Paths;

public class TestZip2 {
    @Test
    public void test1() {
        try (FileOutputStream out = new FileOutputStream("D:\\data\\data\\批量添加全息目标模板2.zip")) {
            ZipUtil.pack(Paths.get("D:\\data\\data\\批量添加全息目标模板").toFile(), out);
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Test
    public void test2() {
        ZipUtil.pack(new File("D:\\data\\uploadfiles\\albumPhoto"), new File("D:\\data\\uploadfiles\\22.zip"), true);
    }

    @Test
    public void test3() throws IOException {
        FileUtil.zip("D:\\data\\uploadfiles\\albumPhoto", "D:\\data\\uploadfiles\\albumPhoto3.zip");
    }

    @Test
    public void test4() {
        Path p1 = Paths.get("D:\\data\\uploadfiles\\albumPhoto");
        Path p2 = Paths.get("D:\\data\\uploadfiles\\albumPhoto", "李四", "低质量人脸");
        System.out.println(p1.relativize(p2).toString());
    }

    @Test
    public void test5() {
        ZipUtil.unpack(new File("D:\\data\\人脸.zip"),new File("D:\\data\\test2"), Charset.forName("GBK"));
    }
}
